<?php

/*
	Class: BlogViewPostsCategories

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>
*/
class BlogViewPostsCategories extends Blog_Db_Table {

    protected $_name = 'blog_vw_posts_categories';

    protected $_primary = array('category_id', 'post_id');

	function getBestCategoryInfoForPost($post_slug, $category_slug = null) {
		$where = $this->getAdapter()->quoteInto("post_slug = ?", $post_slug);
		if (!is_null($category_slug)) {
			$slug_parts = explode(",", $category_slug);
			$where .= "and category_slug like '%".$slug_parts[0]."%'";
		}
		return $this->fetchRowArray($where);
	}

}
